import { defineStore } from 'pinia'

export const useRoutesStore = defineStore('routes', {
  state: () => ({
    routes: JSON.parse(localStorage.getItem('routes') || '[]') as Array<any>,
    currentRoute: null as any
  }),
  actions: {
    setRoutes(routes: Array<any>) {
      this.routes = routes
      localStorage.setItem('routes', JSON.stringify(routes))
    },
    setCurrentRoute(route: any) {
      this.currentRoute = route
    }
  },
  getters: {
    getRoutes: (state) => state.routes,
    getCurrentRoute: (state) => state.currentRoute
  }
})